/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013-2014 jfinal app. jfapp Group.
 */

define(['adminapp'], function ($app) {
    $app.navactive('activity_category');
    var action_tpl = Handlebars.compile($(g.actiontpl).html());

    var $listtable = $app.listtable({
        'sAjaxSource': g.ctx + "admin/activity/category/list",
        'bSort' : false,
        'bAutoWidth':true,
        'fnServerParams': function (aoData) {
            var sd = $('#search_form').serializeJSON();
            $.each(sd, function (name, val) {
                aoData.push({"name": name, "value": val});
            });
        },
        'aoColumns': [
            $app.checkall,
            $app.autono,
            {'mDataProp': 'name'},
            {'mDataProp': 'description' }
        ],
        'aoColumnDefs': [
            {
                'aTargets': [4],
                'mData': null,
                'mRender': function (data, type, full) {
                    return action_tpl(full);
                }
            }
        ]
    }, 'data-list');

    $('#search_btn').on('click', function (e) {
        e.preventDefault();
        $listtable.fnReloadAjax();
    });
});

